var vm = new Vue({
    el:"#checkbox1",
    data:{
        deptInfo:[],
        staffInfo:[],
        staffInfoByQuery: {
            flagList:[]
        },
        staffDeptName:'',
        staffName:'',
        staffId:''
    },
    methods:{
        //渲染部门信息
        getAllDeptInfo:function(){
            axios.post("http://localhost:8099/PersonalInfoQuery/getAllDept").then(
                function(result){
                    vm.deptInfo=result.data;
                    console.log(vm.deptInfo);
                },function (err) {
                    console.log(err);
                }
            )
        },
        //复选框查找员工信息
        getStaffInfo:function(){
            axios.post("http://localhost:8099/PersonalInfoQuery/getStaffInfo",{deptname:vm.staffDeptName}).then(
                function(result){
                    vm.staffInfo=result.data;
                },function (err) {
                    console.log(err);
                }
            )
        },
        //失去部门焦点查找员工信息
        function1:function(){
            vm.staffDeptName=$("#checkbox1_1").val();
            $("#checkbox1_2>option:first-child").attr("selected",true);
            this.getStaffInfo();
        },
        //失去员工焦点查找员工id
        function2:function(){
            vm.staffId=$("#checkbox1_2>option:checked").attr("power");

        },
        //查找员工信息
        checkStaffInfo:function(){
            if(vm.staffId==''){
                alert("请确定员工姓名！")
            }else{
                axios.post("http://localhost:8099/PersonalInfoQuery/getStaffInfo",{id:vm.staffId}).then(
                    function(result){
                        vm.staffInfoByQuery=result.data[0];
                        console.log(vm.staffInfoByQuery);
                    },function (err) {
                        console.log(err);
                    }
                )
            }
        }
    },
    mounted(){
        this.getAllDeptInfo();
    }
})

